<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

/**
 * pad接口针对出租车业务
 */
Route::prefix('v1/pad')->name('pad-api.')->namespace('Pad')->middleware('pad')->group(function () {
    Route::post('login', 'LoginAndLogoutController@login')->name('login');

    Route::middleware('auth:api')->group(function () {
        Route::get('logout', 'LoginAndLogoutController@logout')->name('logout');
        Route::post('taxi/release', 'TaxiController@post')->name('taxi.release');
        Route::post('taxi/release-free', 'TaxiController@freeRelease')->name('taxi.release-free');
        Route::get('taxi-release/{id}', 'TaxiController@query')->name('taxi.release.query');
    });
});


Route::post('v1/login', 'UserController@login')->middleware('log')->name('login');
Route::post('v1/car_auths/save', 'CarAuthAPIController@save')->name('car_auth.save');
Route::get('v1/park_record/list', 'ParkRecordAPIController@index');
Route::get('v1/download', "ParkRecordAPIController@down");
Route::post('v1/enter-and-leaving-car-notice', "EnterAndLeaveCarController@index");
Route::post('v1/enter-and-leaving-car-test', "EnterAndLeaveCarController@test");
Route::get('v1/reports/export', "ReportController@dayReport");
Route::post('v1/get-bank-info', "DataReportAPIController@getBankInfo")->name('report.get.bank.info');  // 通知生成excel
Route::get('v1/mvplnumberlist', 'ParkRecordAPIController@mvplNumberList')->name("park_record.vpl.mlist"); // 车场管家list

Route::post('v1/info-depart/records', "ParkRecordAPIController@records");
Route::post('v1/info-depart/park_info', "ParkInfoAPIController@park_info");


Route::middleware('auth:api','log')->prefix('v1')->group(function () {

    Route::get('logout', 'UserController@logout')->name('logout');

    // Route::group(['middleware' => ['auth.api']], function() {
        Route::get('reports', "ReportController@index");

        Route::put('user/change-password', 'UserAPIController@changePassword')->name("user.chpassword");
        Route::post('user/change-pwd', 'UserAPIController@changePwd')->name("user.chpassword");
        Route::post('user/change-flag', 'UserAPIController@changeFlag')->name("user.chflag");
        Route::get('user/info', 'UserAPIController@info')->name("user.info");
        Route::resource('users', 'UserAPIController');

        Route::resource('organizations', 'OrganizationAPIController');

        Route::resource('roles', 'RoleAPIController');
        Route::get('role/list', 'RoleAPIController@lists')->name('role.list');

        Route::resource('permissions', 'PermissionAPIController');

        Route::resource('selections', 'SelectionAPIController');
        // 菜单管理pay_allfee
        Route::get('menu/list', 'MenuAPIController@lists')->name('menu.list');
        Route::resource('menus', 'MenuAPIController');

        Route::resource('car_auths', 'CarAuthAPIController');   // 车辆授权
        Route::post('mass_auth', 'CarAuthAPIController@massAuth');   // 批量车辆授权
        Route::post('mass_file', 'CarAuthAPIController@massFile');   // 批量授权上传文件
        Route::get('car_auth/log', 'CarAuthAPIController@logList')->name('car_auth.log'); // 车辆授权日志

        Route::resource('park_channels', 'ParkChannelsAPIController');  // patch post
        Route::get('lifting-lever', 'ParkChannelsAPIController@liftingLever')->name('lift.lever');
        Route::post('order-car', 'ParkChannelsAPIController@addOrderCar')->name('order.car');   // 添加预约车队时间
        Route::post('order-code', 'ParkChannelsAPIController@sendLiftCode')->name('order.code'); // 发送车队抬杆命令


        // 数据投屏接口
        Route::get('data-screen/info', 'DataScreenAPIController@info')->name("data-screen.info");


        //车场列表
        Route::get('park/info', 'ParkInfoAPIController@index')->name("park.index");
        Route::post('park/{id}', 'ParkInfoAPIController@update')->name("park.modify");
        Route::delete('park/{id}', 'ParkInfoAPIController@delete')->name("park.delete");
        Route::post('park-set/free-park-times', 'ParkInfoAPIController@freeParkingTimesSet')->name("park.free");

        Route::post('upload/{type}', 'UploadController@index')->name("upload");

        // 停车记录
        Route::get('park_record', 'ParkRecordAPIController@index')->name("park_record.index");
        Route::get('park_record/info', 'ParkRecordAPIController@info')->name("park_record.info");
        Route::get('park_record/detail', 'ParkRecordAPIController@recordDetail')->name("park_record.detail");
        Route::get('park_record/recordnumberlist', 'ParkRecordAPIController@recordNumberList')->name("park_record.record.list");
        Route::get('park_record/vplnumberlist', 'ParkRecordAPIController@vplNumberList')->name("park_record.vpl.list");
        Route::get('park_record/video', 'ParkRecordAPIController@getVideo')->name("park_record.video");
        // 车辆追踪
        Route::get('vpln_record', 'ParkRecordAPIController@VplnRecord')->name("park_record.vpln_record");
        Route::get('vpln_info', 'ParkRecordAPIController@VplnInfo')->name("park_record.vpln_info");
        Route::get('bad_car', 'ParkRecordAPIController@badCar')->name("badCar");
        Route::get('bad_car/info', 'ParkRecordAPIController@badCarInfo')->name("badCar.info");
        Route::get('park_record/etc', 'ParkRecordAPIController@etcRecord')->name("badCar.info");

        Route::resource('devices', 'DeviceAPIController');

        Route::resource('offline_users', 'OfflineUserAPIController');
        Route::post('offline_users/reset_password/{id}', 'OfflineUserAPIController@changePassword')->name("offline.chpwd");
        Route::get('offline_user/parklist', 'OfflineUserAPIController@parkList')->name("offline.parkList");; // 下发车场列表
        Route::post('offline_user/issuePark', 'OfflineUserAPIController@issuePark')->name("offline.issuePark"); // 下发车场列表

        Route::get('pay_allfee', 'ParkRecordAPIController@pay_fee')->name("park.pay_allfee");  // 支付记录

        Route::resource('abnormal_cars', 'AbnormalCarAPIController'); // 不良车记录

        Route::resource('park_datas', 'ParkDataAPIController');  // 停车数据补录

        Route::resource('lift_poles', 'LiftPoleAPIController');  // 抬杆

        Route::get('flow-count', "FlowCountController@index")->name('flow.count');
        Route::get('flow-count-days', "FlowCountController@flowByDay")->name('flow.count.flowByDay');
        Route::get('income', "IncomeAnalysisController")->name('income');
        Route::get('inner-park', "InnerParkCountController@query")->name('inner-car.query');
        Route::get('parking-times/count', "ParkingTimeCountController@query")->name('parking-times.count');  // 免费流量
        Route::get('overview/time-list', "OverViewController@timeList")->name('overview.time-list');  //流量合计
        Route::get('overview/inner-car', "OverViewController@innerCarNum")->name('overview.inner-car');  //场内车
        Route::get('overview/time-count', "OverViewController@timeCount")->name('overview.time-count');  //收入范围
        Route::get('overview/time-total', "OverViewController@timeTotal")->name('overview.time-total');  //流量合计
        Route::get('overview/flow-total', "OverViewController@total")->name('overview.flow-total');  //流量合计
        Route::get('overview/flow-range', "OverViewController@flowRange")->name('overview.flow-range');  //流量范围
        Route::get('overview/charge-total', "OverViewController@chargeTotal")->name('overview.charge-total');  //交易合计
        Route::get('overview/charge-range', "OverViewController@chargeRange")->name('overview.charge-range');  //收入范围

        Route::get('free-record/query', "FreeRecordController@query")->name('free-record.query');  //免费放行

        Route::get('report-allpay', "DataReportAPIController@index")->name('report.pay');  // 支付汇总报表
        Route::get('report-payfee', "DataReportAPIController@pay_fee")->name('report.payfee');  // 支付汇总报表
        Route::get('report-charger', "DataReportAPIController@charger_fee")->name('report.charger');  // 支付汇总报表
        Route::post('report-dayfee', "DataReportAPIController@dayDayFee")->name('report.charger');  // 支付汇总报表
        Route::post('report-bankfee', "DataReportAPIController@reportBankFee")->name('report..bank.charger');  //  对比银行账号
        Route::post('report-etcfee', "DataReportAPIController@reportEtcFee")->name('report..etc.charger');  //  对比ETC账号
        Route::post('bank-file', "DataReportAPIController@bankFile")->name('report.bank.file');  // 支付汇总报表
        Route::get('send-bank-file', "DataReportAPIController@sendBankFile")->name('report.send.bank.file');  // 生成excel
        Route::get('get-bank-file', "DataReportAPIController@getBankFile")->name('report.get.bank.file');  // 下载银行excel

        Route::get('data-analysis', "DataAnalysisAPIController@index")->name('data.analysis');
        Route::get('data-flow', "DataAnalysisAPIController@flowTotal")->name('data.flow'); //流量合计
        Route::get('data-flow/charge', "DataAnalysisAPIController@ChargeTotal")->name('data.flow.charge'); // 收费流量
        Route::get('data-flow/free', "DataAnalysisAPIController@freeTotal")->name('data.flow.free');  // 免费流量

        Route::get('screen/total', "ScreenController@total")->name('screen.total');  // 总流量
        Route::get('screen/time-total', "ScreenController@timeTotal")->name('screen.time.total');  // 总流量
        Route::get('screen/parkcount', "ScreenController@nowParkCount")->name('screen.parkcount');  // 实时在场车
        Route::get('screen/range', "ScreenController@range")->name('screen.range');  // 流量范围
        Route::get('screen/payper', "ScreenController@payTypePer")->name('screen.payTypePer');  // 支付比例
        Route::get('screen/import', "ScreenController@importData")->name('screen.import');  // 支付比例



        Route::get('wechat', "WechatAPIController@index")->name('wechat.truck_order');  // 车位预约
        Route::get('wechat/valet', "WechatAPIController@valetCar")->name('wechat.valet_car');  // 待客泊车
        Route::post('wechat/valet', "WechatAPIController@updateValet")->name('wechat.upvalet');  // 待客泊车

        Route::resource('platform_msgs', 'PlatformMsgAPIController');  // 屏显消息
        Route::get('msg', 'PlatformMsgAPIController@msgs');  // 告警信息
        Route::post('msg-delete', 'PlatformMsgAPIController@msgsDelete');  // 删除告警信息
        Route::post('msg-update', 'PlatformMsgAPIController@msgsUpdate');  // 更新告警信息
        Route::post('msg-flag-update', 'PlatformMsgAPIController@msgsFlag');  // 设置消息已弹出

        Route::get('logs', "LogAPIController@index")->name('log.query');  // 系统日志查询
        Route::get('taxi-info', "TaxiController@query")->name('taxi-info.query');  // 出租车运行查询

        Route::resource('stores', 'StoreAPIController');
        Route::post('store/flag', 'StoreAPIController@flag')->name('store.flag');

        Route::resource('sells', 'SellsAPIController');

        Route::resource('sell_issues', 'SellIssuesAPIController');
        Route::post('sell_issue/mass_file', 'SellIssuesAPIController@massFile');
        Route::post('sell_issue/mass_auth', 'SellIssuesAPIController@massAuth');

        Route::resource('fee_configs', 'FeeConfigAPIController');   // 收费规则下发
        Route::resource('managers', 'ManagerAPIController');  // 车场管家
        Route::post('manager/change-password', 'ManagerAPIController@changePwd');  // 车场管家


        Route::middleware('inner.api')->name('inner-api')->namespace('InnerApi')->group(function () {

            Route::post('park/add-device', 'ParkManagerController@addDevice')->name("device.add");
            //Route::post('park/modify', 'ParkManagerController@modify')->name("park.modify");
            Route::post('park/device-info', 'ParkManagerController@deviceInfo')->name("device.info");
            //Route::post('park/info', 'ParkManagerController@info')->name("park.info");
            Route::post('park/remote-control', 'ParkManagerController@remoteControl')->name("park.add");
            Route::post('park/parking-record', 'ParkManagerController@parkingRecord')->name("parking.record");
            Route::post('park/add-channel', 'ParkManagerController@addChannel')->name("channel.add");

            //vehicle
            Route::post('vehicle-auth/issued', 'VehicleAuthController@issued')->name("vehicle.issued");
            Route::post('vehicle-auth/list', 'VehicleAuthController@veicleInfo')->name("vehicle.list");
            Route::post('vehicle-auth/remove', 'VehicleAuthController@veicleRemove')->name("vehicle.remove");
            Route::post('vehicle-auth/edit', 'VehicleAuthController@veicleEdit')->name("vehicle.edit");
            Route::post('vehicle-auth/add', 'VehicleAuthController@vehicleAdd')->name("vehicle.add");

            Route::post('vehicle-plate/parking-records ', 'VehiclePlateController@parkingRecords')->name("vehicle.records");
        });
    // });


        // 员工车

        // 员工组织架构
        Route::resource('staff/orgs', 'StaffOrgAPIController');
        // 批量设置金额
        Route::patch('staff/org/batch', 'StaffOrgAPIController@batch')->name('staff.org.batch');


        // 批量导入员工信息
        Route::post('staff/info/import', 'StaffInfoAPIController@import')->name('staff.info.import');
        // 员工信息
        Route::resource('staff/infos', 'StaffInfoAPIController');
        // 员工信息审核
        Route::patch('staff/infos/{id}/approve', 'StaffInfoAPIController@approve')
                            ->name('staff.infos.approve');
        // 员工状态变更
        Route::patch('staff/infos/{id}/status', 'StaffInfoAPIController@status')
                            ->name('staff.infos.status');

        // 年卡
        Route::resource('staff/cards', 'StaffCardAPIController');
        // 购买记录
        Route::resource('staff/orders', 'StaffOrderAPIController');



});



// Wechat MiniApp Api
Route::prefix('v1/wechat')->name('wechat.miniapp.api.')->group(function () {

    // callback
    Route::post('payment/callback', 'StaffOrderAPIController@callback')->name('orders.callback');

    // auth
    Route::group(['middleware' => ['wechat.miniapp']], function() {

        // 用户信息
        Route::get('userinfo', 'StaffInfoAPIController@getDetailByMobile')->name('staffinfo.listbyuser');
        // 用户审核通过
        Route::post('audit', 'StaffInfoAPIController@audit')->name('staffinfo.approve');

        // openid
        Route::post('openid', 'StaffOpenidAPIController@store')->name('openid.create');
        Route::patch('openid/{openid}', 'StaffOpenidAPIController@update')->name('openid.update');


        // 订单列表
        Route::get('orders', 'StaffOrderAPIController@listByUid')->name('orders.listbyuser');
        // 订单列表
        Route::post('orders', 'StaffOrderAPIController@store')->name('orders.create');
        // 订单详情
        Route::get('orders/{id}', 'StaffOrderAPIController@show')->name('orders.detail');
        // 订单详情
        Route::delete('orders/{id}', 'StaffOrderAPIController@destroy')->name('orders.destroy');

        // 年卡信息
        Route::get('cards/annual', 'StaffCardAPIController@annualListByUid')->name('cards.annualListByUid');
        // 月卡信息
        Route::get('cards/month', 'StaffCardAPIController@monthListByUid')->name('cards.monthListByUid');

        Route::get('vpl/record', 'ParkRecordAPIController@VplnRecord')->name('vpl.record');

        Route::post('upload', 'StaffInfoAPIController@upload')->name('upload');
        Route::post('attachment', 'StaffInfoAPIController@attachment')->name('attachment');
    });
});



